﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace hw1_1
{
    class Program
    {
        static Boolean ifPrime(int n)//判断是否是素数
        {
            if (n <= 1)
                return false;

            for (int i = 2; i * i <= n; i++)
            {
                if (n % i == 0)
                    return false;
            }

            return true;
        }
        static void Main(string[] args)
        {
            Console.WriteLine("请输入一个整数：");
            int number = Convert.ToInt32(Console.ReadLine());
            Console.WriteLine("该数的素数因子为：");
            int p = 2;
            while (p<= number)
            {
                if (ifPrime(p))
                {
                    if (number % p == 0)
                    {
                        Console.WriteLine(p);
                    }
                }
                p++;  
            }
            Console.Read();
        }
    }
}